package com.itheima.dao;


import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderSettingDao {

    //预约设置信息
    @Select("SELECT DAY(orderDate) date,number,reservations FROM t_ordersetting where orderDate between #{dateBegin} and #{dateEnd}")
    List<Map> getOrderSettingByMonth(@Param("dateBegin") String dateBegin,@Param("dateEnd") String dateEnd);

    //查询是否有该预约日期
    @Select("select count(id) from t_ordersetting where orderDate=#{orderDate}")
    long findCountByOrderDate(Date orderDate);

    //修改 可预约人数
    @Update("update t_ordersetting set number=#{number} where orderDate=#{orderDate}")
    void editNumberByDate(OrderSetting orderSetting);

    //添加一条预约条数
    @Insert("insert into t_ordersetting(id,orderDate,number,reservations) values(#{id},#{orderDate},#{number},#{reservations})")
    void add(OrderSetting orderSetting);


    //查找是否有预约对象
    @Select("select * from t_ordersetting where orderDate=#{date}")
    OrderSetting  findByOrderDate(Date date);

    //修改已预约人数
    @Update("update t_ordersetting set reservations=#{reservations} where orderDate=#{orderDate}")
    void editReservationsByOrderDate(OrderSetting orderSetting);
}
